/*
 * @Author: huzhanglin 799490931@qq.com
 * @Date: 2022-05-29 12:18:44
 * @LastEditors: huzhanglin 799490931@qq.com
 * @LastEditTime: 2022-05-30 23:49:15
 * @FilePath: \vue-next-admin\src\api\dept\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import request from '/@/utils/request';

// 定义接口来定义对象的类型
export interface DeptData {
	deptName: string;
	createTime: string;
	status: boolean;
	sort: number | string;
	describe: string;
	id: number;
	children?: DeptData[];
}

// 定义接口来定义对象的类型
export interface TableDataRow {
	deptName: string;
	createTime: string;
	status: boolean;
	sort: number;
	describe: string;
	id: number;
	level: number;
	children?: TableDataRow[];
}


export interface SimpleDeptInfo {
	deptName: string;
	id: number;
	children: SimpleDeptInfo[];
}

export interface DeptSate {
	isShowDialog: boolean;
	deptForm: {
		pId: number;
		deptName: string;
		person: string;
		phone: string | number;
		email: string;
		sort: number;
		status: number;
		describe: string;
		level: number;
	};
	deptData: Array<SimpleDeptInfo>;
}

export function deptMenuApi() {
	return {
		// post
		addDept: (params: object) => {
			return request({
				url: '/dept',
				method: 'post',
				data: params,
			});
		},
		// get
		getDept: (params: object) => {
			return request({
				url: '/dept',
				method: 'get',
				params,
			})
		},
		initData: () => {
			return {
				deptName: 'vueNextAdmin',
				createTime: new Date().toLocaleString(),
				status: true,
				sort: Math.random(),
				describe: '顶级部门',
				id: Math.random(),
				children: [
					{
						deptName: 'IT外包服务',
						createTime: new Date().toLocaleString(),
						status: true,
						sort: Math.random(),
						describe: '总部',
						id: Math.random(),
					},
					{
						deptName: '资本控股',
						createTime: new Date().toLocaleString(),
						status: true,
						sort: Math.random(),
						describe: '分部',
						id: Math.random(),
					},
				],
			};
		},
	};
}

